﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TinyCinema.UI.Pages.Customer
{
    /// <summary>
    /// Interaction logic for Information.xaml
    /// </summary>
    public partial class Information : Page
    {
        public Information()
        {
            InitializeComponent();
            MainMenu = FindResource("MainMenu") as StackPanel;
            DataContext = dataContext;

            dataContext.SearchFilter.Add(App.Current.FindResource("langCusName") as String);
            dataContext.SearchFilter.Add(App.Current.FindResource("langCusID") as String);
        }
        public static DependencyProperty ContentFrameSourceProperty = DependencyProperty.Register("pagContentFrameSource", typeof(Page), typeof(Information));
        public Page pagContentFrameSource
        {
            get { return (Page)GetValue(ContentFrameSourceProperty); }
            set { SetValue(ContentFrameSourceProperty, value); }
        }
        public StackPanel MainMenu { get; set; }
        public static TinyCinema.Bussiness.Customer.Customer dataContext = new Bussiness.Customer.Customer();
        private void MenuHandle(object sender, RoutedEventArgs e)
        {
            switch ((sender as Button).Uid)
            {
                case "Create": FormViewModeHandle();
                    (DataContext as Bussiness.Customer.Customer).CreateCommand.Execute(null);
                    break;
                case "Edit":
                    break;
                case "Delete":
                    break;
            }
        }
        public static _Information.FormView pagFormView = new _Information.FormView();
        public void FormViewModeHandle()
        {
            if (pagContentFrameSource is _Information.FormView) ViewModeHandle(btnPreViewMode, null);
            pagContentFrameSource = pagFormView;
        }
        Button btnPreViewMode;
        _Information.GridView pagGridView = new _Information.GridView();
        _Information.ListView pagListView = new _Information.ListView();
        void ViewModeHandle(object sender, RoutedEventArgs e)
        {
            switch ((sender as Button).Uid)
            {
                case "GridView":
                    pagContentFrameSource = pagGridView;
                    break;
                case "ListView": pagContentFrameSource = pagListView;
                    break;
            }
            (sender as Button).IsEnabled = false;
            try
            {
                btnPreViewMode.IsEnabled = true;
            }
            catch { }
            btnPreViewMode = sender as Button;
        }
        private void ViewModeHandle(object sender, EventArgs e)
        {
            ViewModeHandle(sender, new RoutedEventArgs());
        }
        private void MainMenuInitialized(object sender, EventArgs e)
        {
            (sender as StackPanel).DataContext = dataContext;
        }
    }

}
